Android de Web Servisten Gelen String Değerini Okuma
public class MainActivity extends Activity {
private final String NAMESPACE="http://www.tempuri.org/";
private final String URL="http://10.71.21.16:8080/EDIZ/service.asmx";
private final String SOAP_ACTION="http://tempuri.org/FirmaGetirIsmeGoreText";
private final String METHOD_NAME="FirmaGetirIsmeGoreText";
private String TAG = "PGGURU";
private static String Sirket;
private static String SirketGet;
private static String Firma;
private static String FirmaGet;
private static String Alanlar;
private static String AlanlarGet;
private static String Where;
private static String WhereGet;
Button b;
TextView tv1;
EditText et1;
TextView tv2;
EditText et2;
TextView tv3;
EditText et3;
TextView tv4;
EditText et4;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1 = (EditText) findViewById(R.id.editText1);
tv1 = (TextView) findViewById(R.id.tv_result);
et2 = (EditText) findViewById(R.id.editText2);
et3 = (EditText) findViewById(R.id.editText3);
et4 = (EditText) findViewById(R.id.editText4);
b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (et1.getText().length() != 0 && et1.getText().toString() != "") {
Sirket = et1.getText().toString();
Firma = et2.getText().toString();
Alanlar = et3.getText().toString();
Where = et4.getText().toString();
AsyncCallWS task = new AsyncCallWS();
task.execute();
} else {
tv1.setText("Please enter Celcius");
}
}
});
}
public void getFahrenheit(String sirketx,String firmax,String alanlarx,String wherex) {
//Create request
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo sirketPI = new PropertyInfo();
sirketPI.setName("p_sirketid");
sirketPI.setValue(sirketx);
sirketPI.setType(sirketPI.getClass());
request.addProperty(sirketPI);
PropertyInfo firmaPI = new PropertyInfo();
firmaPI.setName("p_FirmaAdi");
firmaPI.setValue(firmax);
firmaPI.setType(firmaPI.getClass());
request.addProperty(firmaPI);
PropertyInfo AlanlarPI = new PropertyInfo();
AlanlarPI.setName("p_SecenekAlanlar");
AlanlarPI.setValue(alanlarx);
AlanlarPI.setType(AlanlarPI.getClass());
request.addProperty(AlanlarPI);
PropertyInfo WhereKriteriPI = new PropertyInfo();
WhereKriteriPI.setName("p_WhereKriteri");
WhereKriteriPI.setValue(wherex);
WhereKriteriPI.setType(WhereKriteriPI.getClass());
request.addProperty(WhereKriteriPI);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
//String result = envelope.getResponse().toString();
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
StringBuilder strekle = new StringBuilder();
strekle.append(response.toString()+"\n");//Assign it to fahren static variable
SirketGet = strekle.toString();
} catch (Exception e) {
e.printStackTrace();
}
}
private class AsyncCallWS extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
Log.i(TAG, "doInBackground");
getFahrenheit(Sirket, Firma, Alanlar, Where);
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.i(TAG, "onPostExecute");
tv1.setText(SirketGet + "° F");
}
@Override
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
tv1.setText("Bağlanıyor...");
}
@Override
protected void onProgressUpdate(Void... values) {
Log.i(TAG, "onProgressUpdate");
}
}
}
Merhaba Arkadaşlar.Şu an elimde böyle bir kod var.Web servise 4 tane parametre gönderiyorum.Bu parametrelerin 1 tanesi integer diğer 3 tanesi string türünde.Web servise bilgileri gönderiyorum ama gelen string değeri işleyemiyorum.Web servise bağlanmada mı sorun var yoksa gelen string değeri mi işleyemiyorum anlayamadım.Yardımcı olursanız sevinirim..